home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Camelot / Camelot 030 (1988-11)(Swedish User Group of Amiga)(SE)(PD)[WB].zip / Camelot 030 (1988-11)(Swedish User Group of Amiga)(SE)(PD)[WB].adf / dis / lex.l < prev    next >
Text File  |  1988-11-12  |  817b  |  61 lines

  1. %{
  2. #undef ECHO
  3. #include "dis.h"
  4. int lineno = 0;
  5. char *strcpy();
  6. %}
  7. %%
  8. [ \t] { ; }
  9. [\n] {    lineno++;
  10.                 return '\n';
  11. }
  12. \.EQ { 
  13.                 return EQ;
  14. }
  15. \.LI { 
  16.                 return LI;
  17. }
  18. \.eq { 
  19.                 return EQ;
  20. }
  21. \.li { 
  22.                 return LI;
  23. }
  24. ".trace" {
  25.                 return TSTART;
  26. }
  27. ".stop" {
  28.                 return TSTOP;
  29. }
  30. [0-9]+    {
  31.                 (void)sscanf(yytext, "%d", &token.ival); 
  32.                 return NUMBER;
  33. }
  34. \$[A-Fa-f0-9]+ {
  35.                 (void)sscanf(yytext+1, "%x", &token.ival);
  36.                 return NUMBER;
  37. }
  38. [A-Za-z][A-Za-z0-9_]* {
  39.                 token.sval = emalloc((unsigned) strlen(yytext)+1);
  40.                 (void)strcpy((char *)token.sval, (char *)yytext);
  41.                 return NAME;
  42. }
  43. \*.* {
  44.                 return COMMENT;
  45. }
  46. .            { return yytext[0]; }
  47. %%
  48.  
  49. char *
  50. emalloc(n)
  51. unsigned n;
  52. {
  53.     char *ptr, *malloc();
  54.  
  55.     if ((ptr = malloc(n)) == (char *) 0) {
  56.         (void) fprintf(stderr,"out of core");
  57.         exit(1);
  58.     }
  59.     return ptr;
  60. }
  61.